<?php
declare (strict_types=1);

namespace app\common\tool;

class Result extends \think\Response
{
    public static function success($msg = 'ok', $data = [], $code = 1, $header = [], $options = [])
    {
        return parent::create([
            'code' => $code,
            'msg'  => $msg,
            'data' => $data
        ], 'json')->header($header)->options($options);

    }

    public static function fail($msg = 'fail', $data = [], $code = -1, $header = [], $options = [])
    {
        return parent::create([
            'code' => $code,
            'msg'  => $msg,
            'data' => $data
        ], 'json')->header($header)->options($options);
    }

    public static function fastReturn($data, $header = [], $options = [])
    {
        return parent::create($data, 'json')->header($header)->options($options);
    }
}